#!/bin/bash

if ! command -v docker > /dev/null 2>&1;
    echo 'Please install docker before executing'
    exit 1
fi

# 收集容器运行状态
docker run \
  --volume=/:/rootfs:ro \
  --volume=/var/run:/var/run:ro \
  --volume=/sys:/sys:ro \
  --volume=/var/lib/docker/:/var/lib/docker:ro \
  --volume=/dev/disk/:/dev/disk:ro \
  --publish=8080:8080 \
  --detach=true \
  --name=cadvisor \
  google/cadvisor:latest

echo "cadvisor dashboard: https://grafana.com/grafana/dashboards/193"
echo
echo "metrics:  http://$(hostname -i):8080/metrics"